<template>
  <basic-container :btnFlag=true>
    <div class="card-border">
      <card-header :header-data="headerData"></card-header>
      <div style="margin-left: 9px;margin-top: -38px;">
        <bostech-detail :detail-data="detailData1"></bostech-detail>
      </div>
      <div style="float: right;margin-right: 30px">
        <el-button type="primary" size="mini" @click="subjectLevy()">课题征集</el-button>
        <el-button type="warning" size="mini" @click="subjectLevyResult()">课题征集结果</el-button>
        <el-button type="success" size="mini" @click="addSubject()">增加课题</el-button>
      </div>
      <span style="font-weight: 600;margin-left: 10px">课题列表</span>
      <div class="card-body">
        <avue-crud :data="subjectListData"
                   :option="tableoption"
                   :page="page"
                   :table-loading="tableLoading"
                   @on-load="getResultList"
                   @refresh-change="refreshChange"
                   @search-change="searchChange"
                   class="avuecrud">
          <template slot-scope="scope" slot="menu">
            <div class="menu-title" @click.stop="subjectDetail(scope.row,scope.index)">
              <i class="iconfont iconview icon-primary"></i>
              <p class="menu-title-text">查看</p>
            </div>
            <div class="menu-title" @click.stop="editSubject(scope.row,scope.index)">
              <i class="iconfont iconalter icon-warning"></i>
              <p class="menu-title-text">编辑</p>
            </div>
            <div class="menu-title" @click.stop="subjectEdit(scope.row,scope.index)">
              <i class="iconfont iconview icon-primary"></i>
              <p class="menu-title-text">成果录入</p>
            </div>
          </template>
        </avue-crud>
      </div>
    </div>
  </basic-container>
</template>

<script>
  import {getSubjectList} from "@/api/subject";

  export default {
    name: "subjectLevySummary",
    created() {
      this.detailData1 = [{label: '规划名称', value: this.$route.query.title},
        {label: '规划编码', value: this.$route.query.pmuc}];
    },
    data() {
      return {
        headerData: {
          title: '课题拟定'
        },
        subjectListData: [],
        tableoption: {
          page: true,
          menuWidth: 260,
          addBtn: false,
          editBtn: false,
          addRowBtn: false,
          indexLabel: "序号",
          index: true,
          cellBtn: false,
          indexWidth:70,
          delBtn: false,
          columnBtn: false,
          refreshBtn: false,
          filterBtn: false,
          searchBtn: false,
          keyId: "id",
          column: [
            {
              label: "课题名称",
              width: 200,
              prop: "title",
              cell: true
            },
            {
              label: "课题描述",
              width: 200,
              prop: "description",
              cell: true
            },
            {
              label: "创建时间",
              width: 180,
              prop: "createTime",
              cell: true
            },
            {
              label: "创建单位",
              width: 100,
              prop: "createUserId",
              cell: true
            },

          ]
        },
        detailData1: [],
        tableLoading: false,
      }
    },
    methods: {
      // 课题编制跳转
      subjectEdit(row, index) {
        let src = `/subjectEdit/detail/${row.subjectId}`;
        this.$router.push({
          path: src
        })
      },
      // 课题征集跳转
      subjectLevy() {
        let src = `/subjectLevy/detail/${this.$route.params.id}`;
        this.$router.push({
          path: src
        })
      },
      // 课题征集结果跳转
      subjectLevyResult() {
        let src = `/subjectLevyResult/detail/${this.$route.params.id}`;
        this.$router.push({
          path: src
        })
      },
      // 增加课题跳转
      addSubject() {
        let src = `/addSubject/detail/${this.$route.params.id}`;
        this.$router.push({
          path: src
        })
      },
      // 编辑课题跳转
      editSubject(row) {
        let src = `/editSubject/detail/${row.subjectId}`;
        this.$router.push({
          path: src
        })
      },
      // 课题详情跳转
      subjectDetail(row) {
        let src = `/subjectDetail/detail/${row.subjectId}`;
        this.$router.push({
          path: src
        })
      },
      subjectDelete() {
        this.$confirm("确定删除此课题吗?", "提示", {
          confirmButtonText: "确定",
          cancelButtonText: "取消",
          type: "warning"
        }).then(() => {

        })
      },
      searchChange() {

      },
      refreshChange() {

      },
      getResultList() {
        getSubjectList(Object.assign({
          achievementId: this.$route.params.id,
        })).then(response => {
          this.subjectListData = response.data.data.records;
        })
      },
    }
  }
</script>

<style lang="scss" scoped>
  .card-body {
    padding: 10px;
  }
</style>
